package com.urea.web.controller.urea;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.urea.common.annotation.Log;
import com.urea.common.core.controller.BaseController;
import com.urea.common.core.domain.AjaxResult;
import com.urea.common.enums.BusinessType;
import com.urea.system.domain.RechargePackage;
import com.urea.system.service.IRechargePackageService;
import com.urea.common.utils.poi.ExcelUtil;
import com.urea.common.core.page.TableDataInfo;

/**
 * 充值套餐Controller
 * 
 * @author liuzd
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/recharge/package")
@Api(tags = "充值套餐")
public class RechargePackageController extends BaseController
{
    @Autowired
    private IRechargePackageService rechargePackageService;

    /**
     * 查询充值套餐列表
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:list')")
    @GetMapping("/list")
    @ApiOperation("套餐列表")
    public TableDataInfo list(RechargePackage rechargePackage)
    {
        startPage();
        List<RechargePackage> list = rechargePackageService.selectRechargePackageList(rechargePackage);
        return getDataTable(list);
    }

    /**
     * 导出充值套餐列表
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:export')")
    @Log(title = "充值套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出充值套餐列表")
    public void export(HttpServletResponse response, RechargePackage rechargePackage)
    {
        List<RechargePackage> list = rechargePackageService.selectRechargePackageList(rechargePackage);
        ExcelUtil<RechargePackage> util = new ExcelUtil<RechargePackage>(RechargePackage.class);
        util.exportExcel(response, list, "充值套餐数据");
    }

    /**
     * 获取充值套餐详细信息
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取充值套餐详细信息")
    public AjaxResult getInfo(@ApiParam(name = "id") @PathVariable("id") Long id)
    {
        return success(rechargePackageService.selectRechargePackageById(id));
    }

    /**
     * 新增充值套餐
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:add')")
    @Log(title = "充值套餐", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增充值套餐")
    public AjaxResult add(@RequestBody RechargePackage rechargePackage)
    {
        return toAjax(rechargePackageService.insertRechargePackage(rechargePackage));
    }

    /**
     * 修改充值套餐
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:edit')")
    @Log(title = "充值套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改充值套餐")
    public AjaxResult edit(@RequestBody RechargePackage rechargePackage)
    {
        return toAjax(rechargePackageService.updateRechargePackage(rechargePackage));
    }

    /**
     * 删除充值套餐
     */
//    @PreAuthorize("@ss.hasPermi('recharge:package:remove')")
    @Log(title = "充值套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("充值套餐")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rechargePackageService.deleteRechargePackageByIds(ids));
    }

    @Log(title = "充值套餐", businessType = BusinessType.DELETE)
    @PostMapping("/remove1")
    @ApiOperation("充值套餐111")
    @ApiResponse(code=200,response = RechargePackage.class,message = "充值信息")
    public RechargePackage remove1(@RequestBody RechargePackage en)
    {
        return new RechargePackage();
    }
}
